package biz.impl;

import biz.UsersBiz;
import mapper.UsersMapper;
import org.apache.ibatis.session.SqlSession;
import org.example.bean.MemberInfo;
import org.example.bean.MembershipInfo;
import org.example.bean.UsersInfo;


public class UsersBizImpl implements UsersBiz {
    private UsersMapper um;
    private SqlSession session;

    public UsersBizImpl(SqlSession session) {
        this.session = session;
        um = session.getMapper(UsersMapper.class);
    }

    @Override
    public UsersInfo findUsersByPhone(String phone, String pass) {
        return um.findUsersByPhone(phone,pass);
    }

    @Override
    public void saveUsers(UsersInfo ui) {
        um.saveUsers(ui);
        session.commit();
    }

    @Override
    public MemberInfo findMemberById(int uid) {
        return um.findMemberById(uid);
    }

    @Override
    public MembershipInfo findMembershipById(int id) {
        return um.findMembershipById(id);
    }

    @Override
    public void saveMember(int userId) {
        um.saveMember(userId);
        session.commit();
    }

    @Override
    public void saveUsersId(int userId) {
        um.saveUsersId(userId);
        session.commit();
    }
}
